package com.tao.aszx.manager.controller;

import com.github.pagehelper.PageInfo;
import com.tao.aszx.manager.service.CourierService;
import com.tao.aszx.manager.service.SysUserService;
import com.tao.aszx.model.dto.system.SysRole;
import com.tao.aszx.model.dto.system.SysUserDto;
import com.tao.aszx.model.entity.system.Couriers;
import com.tao.aszx.model.entity.system.SysUser;
import com.tao.aszx.model.vo.common.Result;
import com.tao.aszx.model.vo.common.ResultCodeEnum;
import com.tao.aszx.model.vo.system.ValidateCodeVo;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/admin/system/couriers")
public class CouriersController {
    @Autowired
    CourierService courierService;

    @GetMapping("/findAll")
    public Result findAll() {
        List<Couriers> couriersList=courierService.findAll();
        return Result.build(couriersList,200,"查询成功");
    }


        @GetMapping(value = "/findByPage/{pageNum}/{pageSize}")
        public Result<PageInfo<Couriers>> findByPage(String userName,
                                                    @PathVariable(value = "pageNum") Integer pageNum ,
                                                    @PathVariable(value = "pageSize") Integer pageSize) {
            PageInfo<Couriers> pageInfo = courierService.findByPage(userName , pageNum , pageSize) ;
            return Result.build(pageInfo, ResultCodeEnum.SUCCESS) ;
        }

        @PutMapping(value = "/updateCouriers")
        public Result updateSysUser(@RequestBody Couriers couriers) {
            courierService.updateCouriers(couriers) ;
            return Result.build(null , ResultCodeEnum.SUCCESS) ;
        }


        @PostMapping(value = "/saveCouriers")
        public Result saveSysUser(@RequestBody Couriers couriers) {
            System.out.println(couriers);
            courierService.saveSysUser(couriers) ;

            return Result.build(null , ResultCodeEnum.SUCCESS) ;
        }

        @DeleteMapping(value = "/deleteCouriers/{id}")
        public Result deleteById(@PathVariable Integer id){
            courierService.deleteById(id) ;
            return Result.build(null , ResultCodeEnum.SUCCESS) ;
        }




}
